import http from '../../../../base/api/public'
import querystring from 'querystring'
let sysConfig = require('../../../../../config/sysConfig')
let apiUrl = sysConfig.xcApiUrlPre

// 定义方法，请求服务端的页面查询接口

// 分页查询CmsPage
// page要查询的页数，size要显示多少，params参数
export const pageList = (page, size, params) => {
  // 使用queryString可以快速拼接 Url中的 ?key=value&key=value
  let queryString = querystring.stringify(params)
  // 调用http库中的requestQuickGet获取数据
  return http.requestQuickGet(`${apiUrl}/cms/page/list/${page}/${size}?${queryString}`)
}

// 新增一个页面
export const pageAdd = params => {
  return http.requestPost(`${apiUrl}/cms/page/add/`, params)
}
// 根据CmsPageId查询一个CmsPage
export const pageOne = (pageId) => {
  return http.requestQuickGet(`${apiUrl}/cms/page/get/${pageId}`)
}
// 修改一个页面
export const pageEdit = (pageId, params) => {
  return http.requestPut(`${apiUrl}/cms/page/edit/${pageId}`, params)
}
// 删除一个页面
export const pageDelete = (pageId) => {
  return http.requestDelete(`${apiUrl}/cms/page/del/${pageId}`)
}
// 发布一个页面
export const postCmsPage = pageId => {
  return http.requestPost(`${apiUrl}/cms/page/postCmsPage/${pageId}`)
}
